package com.googlecode.tabletags.views.jsp.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;

import com.googlecode.tabletags.components.Pager;
import com.opensymphony.xwork2.util.ValueStack;

/**
 * @see Pager
 */
public class PagerTag extends AbstractURLComponentTag {
    // Pager attributes
    protected String pagerCommand;
    protected String pagerValue;

    /**
     * @see org.apache.struts2.views.jsp.ComponentTagSupport#getBean(com.opensymphony.xwork2.util.ValueStack,
     *      javax.servlet.http.HttpServletRequest,
     *      javax.servlet.http.HttpServletResponse)
     */
    public Component getBean(ValueStack stack, HttpServletRequest req,
        HttpServletResponse res) {
        return new Pager(stack, req, res);
    }

    /**
     * @see com.opensymphony.webwork.views.jsp.ui.AbstractUITag#populateParams()
     */
    protected void populateParams() {
        super.populateParams();

        Pager pager = ((Pager) component);
        pager.setPagerCommand(pagerCommand);
        pager.setPagerValue(pagerValue);
    }

    public void setPagerCommand(String pagerCommand) {
        this.pagerCommand = pagerCommand;
    }

    public void setPagerValue(String pagerValue) {
        this.pagerValue = pagerValue;
    }
}
